<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no,minimal-ui">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="description" content="测试">
    <meta name="keywords" content="测试">
    <title>测试</title>
    <link href="/static/css/bootstrap.css" rel="stylesheet">
    <link href="/static/css/bootstrapValidator.min.css" rel="stylesheet">

    <!--动态设置文字大小-->
    <script>
        var iWidth = document.documentElement.clientWidth;
        document.getElementsByTagName('html')[0].style.fontSize = iWidth / 16 + 'px';
    </script>
</head>

<body>
<div class="app-container">

    <form id="defaultForm" method="post" class="form-horizontal" action="target.php">
        <div class="form-group">
            <label class="col-lg-3 control-label">Full name</label>
            <div class="col-lg-4">
                <input type="text" class="form-control" name="firstName" placeholder="First name" />
            </div>
            <div class="col-lg-4">
                <input type="text" class="form-control" name="lastName" placeholder="Last name" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">Username</label>
            <div class="col-lg-5">
                <input type="text" class="form-control" name="username" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">Email address</label>
            <div class="col-lg-5">
                <input type="text" class="form-control" name="email" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">Password</label>
            <div class="col-lg-5">
                <input type="password" class="form-control" name="password" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">Retype password</label>
            <div class="col-lg-5">
                <input type="password" class="form-control" name="confirmPassword" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">Gender</label>
            <div class="col-lg-5">
                <div class="radio">
                    <label>
                        <input type="radio" name="gender" value="male" /> Male
                    </label>
                </div>
                <div class="radio">
                    <label>
                        <input type="radio" name="gender" value="female" /> Female
                    </label>
                </div>
                <div class="radio">
                    <label>
                        <input type="radio" name="gender" value="other" /> Other
                    </label>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">Birthday</label>
            <div class="col-lg-5">
                <input type="text" class="form-control" name="birthday" /> (YYYY/MM/DD)
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">Languages</label>
            <div class="col-lg-5">
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="languages[]" value="english" /> English
                    </label>
                </div>
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="languages[]" value="french" /> French
                    </label>
                </div>
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="languages[]" value="german" /> German
                    </label>
                </div>
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="languages[]" value="russian" /> Russian
                    </label>
                </div>
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="languages[]" value="other" /> Other
                    </label>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">Programming Languages</label>
            <div class="col-lg-5">
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="programs[]" value="net" /> .Net
                    </label>
                </div>
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="programs[]" value="java" /> Java
                    </label>
                </div>
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="programs[]" value="c" /> C/C++
                    </label>
                </div>
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="programs[]" value="php" /> PHP
                    </label>
                </div>
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="programs[]" value="perl" /> Perl
                    </label>
                </div>
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="programs[]" value="ruby" /> Ruby
                    </label>
                </div>
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="programs[]" value="python" /> Python
                    </label>
                </div>
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="programs[]" value="javascript" /> Javascript
                    </label>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label" id="captchaOperation"></label>
            <div class="col-lg-2">
                <input type="text" class="form-control" name="captcha" />
            </div>
        </div>

        <div class="form-group">
            <div class="col-lg-9 col-lg-offset-3">
                <button type="submit" class="btn btn-primary" name="signup" value="Sign up">Sign up</button>
                <button type="submit" class="btn btn-primary" name="signup2" value="Sign up 2">Sign up 2</button>
                <button type="button" class="btn btn-info" id="validateBtn">Manual validate</button>
                <button type="button" class="btn btn-info" id="resetBtn">Reset form</button>
            </div>
        </div>
    </form>


</div>
<script src="/static/js/jquery-3.3.1.min.js"></script>
<script src="/static/js/bootstrap.min.js" ></script>
<script src="/static/js/bootstrapValidator.min.js" ></script>
<script src="/static/js/language/zh_CN.js" ></script>
<script>
    $(document).ready(function () {
        $("#defaultForm").bootstrapValidator({
            // live: 'disabled',
            message: 'This value is not valid',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                username: {
                    message: '用户名无效',
                    validators: {
                        notEmpty: {
                            message: '用户名不能位空'
                        },
                        stringLength: {
                            min: 6,
                            max: 30,
                            message: '用户名必须大于6，小于30个字'
                        },
                        regexp: {
                            regexp: /^[a-zA-Z0-9_\.]+$/,
                            message: '用户名只能由字母、数字、点和下划线组成'
                        },
                        remote: {
                            url: '#',
                            message: '用户名不可用'
                        },
                        different: {
                            field: 'password',
                            message: '用户名和密码不能相同'
                        }
                    }
                },
                email: {
                    validators: {
                        emailAddress: {
                            message: '输入不是有效的电子邮件地址'
                        }
                    }
                },
                password: {
                    validators: {
                        notEmpty: {
                            message: '密码不能位空'
                        },
                        identical: {
                            field: 'confirmPassword',
                            message: '两次密码不一致'
                        },
                        different: {
                            field: 'username',
                            message: '用户名和密码不能相同'
                        }
                    }
                },
                confirmPassword: {
                    validators: {
                        notEmpty: {
                            message: '密码不能为空'
                        },
                        identical: {
                            field: 'password',
                            message: '两次密码不一致'
                        },
                        different: {
                            field: 'username',
                            message: '用户名和密码不能相同'
                        }
                    }
                },
                birthday: {
                    validators: {
                        date: {
                            format: 'YYYY/MM/DD',
                            message: '不是合法的生日'
                        }
                    }
                },
                gender: {
                    validators: {
                        notEmpty: {
                            message: '请选择性别'
                        }
                    }
                },
                'languages[]': {
                    validators: {
                        notEmpty: {
                            message: '请至少选择一种语言'
                        }
                    }
                },
                'programs[]': {
                    validators: {
                        choice: {
                            min: 2,
                            max: 4,
                            message: '请选择两种到四种语言'
                        }
                    }
                },
                captcha: {
                    validators: {
                        callback: {
                            message: '答案错误',
                            callback: function(value, validator) {
                                var items = $('#captchaOperation').html().split(' '), sum = parseInt(items[0]) + parseInt(items[2]);
                                return value == sum;
                            }
                        }
                    }
                }
            }
        });
        // Validate the form manually
        $('#validateBtn').click(function() {
            $('#defaultForm').bootstrapValidator('validate');
        });

        $('#resetBtn').click(function() {
            $('#defaultForm').data('bootstrapValidator').resetForm(true);
        });
    })
</script>
</body>

</html>